<script setup lang="ts">
import {NRadioGroup, NRadioButton} from 'naive-ui'
import {StnRadioBtnGroupProps} from './types.ts'

/**
 * 组件配置选项
 */
defineOptions({
  name: 'StnRadioBtnGroup',
})

/**
 * 组件参数
 */
const {
  options = [],
  radioGroupProps = {},
} = defineProps<StnRadioBtnGroupProps>()

/**
 * 组件双向绑定
 */
const value = defineModel<string | number | boolean | null>('value', {default: null})
</script>

<template>
  <n-radio-group
    v-bind="{
      ...radioGroupProps,
      value,
      'onUpdate:value': (newVal: string | number | boolean | null) => value = newVal,
    }"
  >
    <n-radio-button
      v-for="(option, index) in options"
      :key="index"
      v-bind="option"
    />
  </n-radio-group>
</template>

<style scoped>
.stn-radio-btn-group {
  color: inherit;
}
</style>
